package com.silence.ByteDance;

// 徒步1
public class easy_60 {
    public static int solution(int n, int k, int[][] p) {
        // Edit your code here
        // n 天数
        // k 补给站个数
        int minPrice = p[0][1];
        int count = 0;
        for (int i = 1; i < k; i++) {
            count += (p[i][0] - p[i - 1][0]) * minPrice;
            if (p[i][1] < minPrice) {
                minPrice = p[i][1];
            }
        }
        count += (n-p[k-1][0]) * minPrice;
        return count;
    }

    public static void main(String[] args) {
        // Add your test cases here
        System.out.println(solution(5, 4, new int[][]{{0, 2}, {1, 3}, {2, 1}, {3, 2}}) == 7);
        System.out.println(solution(5, 4, new int[][]{{0, 1}, {1, 2}, {2, 2}, {3, 2}}) == 5);
        System.out.println(solution(5, 4, new int[][]{{0, 4}, {1, 3}, {2, 2}, {3, 1}}) == 11);
    }
}

